<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
  <input type="text" placeholder="请输入一个1——100的数字" v-model="number">
  <input type="button" value="猜一猜" @click="f()">
  <h1>{{result}}</h1>
</div>
<script src="js/vue.min.js"></script>
<script>
  //得到1——100之间的随机整数
  let x = parseInt(Math.random()*100)+1;
  let v = new Vue({
    el:"body>div",
    data:{
      result:"",
      number:""
    },
    methods:{
      f(){
        if (v.number>x){
          v.result="猜大了"
        }else if (v.number<x){
          v.result="猜小了"
        }else {
          v.result="恭喜你，猜对了"
        }
      }
    }
  });
</script>
</body>
</html>